package com.cloudfun.campusshare.controller;

import com.cloudfun.campusshare.common.constant.Code;
import com.cloudfun.campusshare.common.constant.RoleType;
import com.cloudfun.campusshare.common.model.vo.DeviceModeVO;
import com.cloudfun.campusshare.common.response.BaseResult;
import com.cloudfun.campusshare.common.response.BaseResultFactory;
import com.cloudfun.campusshare.common.security.AuthRequired;
import com.cloudfun.campusshare.service.DeviceModeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by Huqin on 2020/4/21
 */
@Slf4j
@RestController
@RequestMapping("/v1/deviceMode")
@Api(value = "设备模式模块", description = "设备模式模块")
public class DeviceModeController {

    @Autowired
    private DeviceModeService deviceModeService;

    @ApiOperation(value = "客户获取设备模式", notes = "客户获取设备模式")
    @GetMapping("/byDeviceId")
    @AuthRequired(role = RoleType.CUSTOMER)
    public BaseResult<List<DeviceModeVO>> getModeByImei(@ApiParam(value = "设备机器码", required = true) @RequestParam String machineNo) {
        return BaseResultFactory.produceResult(Code.SUCCESS, deviceModeService.getMerchantModeVOsByMachineNo(machineNo));
    }

}
